﻿@model IEnumerable<Tag>
@if (Model != null)
{
    IUser currentUser = UserContext.CurrentUser;
    bool isSpaceUser = currentUser != null && currentUser.UserName.Equals(Url.SpaceKey(), StringComparison.CurrentCultureIgnoreCase);
    <div id="FollowTopics" class="tn-box tn-widget tn-widget-content tn-corner-all">
        <div class="tn-box-header tn-widget-header tn-corner-top tn-border-bottom">
            <h3 class="tn-helper-reset">
               @(isSpaceUser?"我":"Ta")关注的话题</h3>
        </div>
        <div class="tn-box-content tn-widget-content tn-corner-bottom">
            <div class="tn-sort-list">
                @if (Model.Count() > 0)
                {
                    <ul class="tn-list">
                        @foreach (Tag tag in Model)
                        {
                            <li>
                                @if (isSpaceUser)
                                { 
                                    <em nodetype="delFollowTopic" data="@tag.TagId" class="tn-text-note tn-helper-right" style="font-weight: bolder; cursor: pointer; display:none;">
                                        × &nbsp; </em>
                                }
                                @Html.Link(StringUtility.Trim(tag.TagName, 10, ""), SiteUrls.Instance().MicroblogTopic(tag.TagName), tag.TagName, navigateTarget: HyperLinkTarget._blank)
                            </li>
                        }
                    </ul>
                }
                else
                {
                    <text>还没有关注过话题</text>
                }
            </div>
        </div>
    </div>
    if (isSpaceUser)
    {
       <script type="text/javascript">
        $(document).ready(function () {
            $("em[nodetype='delFollowTopic']").click(function () {
                delbtn = $(this);
                var id = delbtn.attr('data');
                $.get('@SiteUrls.Instance()._CancelFollowedTopic(currentUser.UserName, 0)', { tagId: id }, function (data) {
                    if (data.MessageType == 1) {
                        delbtn.parent('li').remove();
                    }
                    else {
                        alert(data.MessageContent);
                    }
                });
            });

        });
    </script>
    }
    <script type="text/javascript">
        $(document).ready(function () {
            $('#FollowTopics li').hover(function () {
                $(this).find('em.tn-text-note').show();
            }, function () {
                $(this).find('em.tn-text-note').hide();
            });
        });
    </script>
}